package com.bnz.controller;

import com.bnz.pojo.Course;
import com.bnz.pojo.Score;
import com.bnz.pojo.Student;
import com.bnz.service.CourseService;
import com.bnz.service.ScoreService;
import com.bnz.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    @Autowired
    private CourseService courseService;
    @Autowired
    private ScoreService scoreService;
    // 1. 列表学生信息
    @RequestMapping("/list")
    public String list(Model model){
        // 1.1 查询所有学生
        List<Student> students = studentService.findAll();
        // 1.2 查询所有课程
        List<Course> courses = courseService.findAll();
        // 1.3 查询所有成绩
        List<Score> scores = scoreService.findll();
        // 1.2 将查询到的信息放在model中
        model.addAttribute("student",students);
        model.addAttribute("score",scores);
        model.addAttribute("course",courses);
        // 1.3 返回视图
        return ("student/list");
    }

}
